﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using DataAccessClass;

namespace ProducerBO
{
    public class LINKS
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _L_ID = -99;
        private string _L_NAME = "";
        private string _L_URL = "";
        private bool _ISDELETED = false;
        //private bool _ISACTIVE = true;

        public bool ISDELETED
        {
            get
            {
                return _ISDELETED;
            }
            set
            {
                _ISDELETED = value;
            }
        }
        /* public bool ISACTIVE
         {
             get
             {
                 return _ISACTIVE;
             }
             set
             {
                 _ISACTIVE = value;
             }
         }*/

        public long L_ID
        {
            get
            {
                return _L_ID;
            }
            set
            {
                _L_ID = value;
            }
        }


        public string L_NAME
        {
            get
            {
                return _L_NAME;
            }
            set
            {
                _L_NAME = value;
            }
        }

        public string L_URL
        {
            get
            {
                return _L_URL;
            }
            set
            {
               _L_URL = value;
            }
        }
        public long SaveRecord()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@L_ID", L_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@L_NAME", L_NAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@L_URL", L_URL, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@ISDELETED", ISDELETED, DbType.Boolean, ParameterDirection.Input);
                //DbParameter dbparam4 = DAC.Parameter("@ISACTIVE", ISACTIVE, DbType.Boolean, ParameterDirection.Input);

                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3};
                return DAC.Save("LINKS_SAVE", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long L_ID, string L_NAME, string L_URL, bool ISDELETED, string andor)//, bool ISACTIVE)
        {
            try
            {

                DbParameter dbparam0 = DAC.Parameter("@L_ID", L_ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@L_NAME", L_NAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@L_URL", L_URL, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@ISDELETED", ISDELETED, DbType.Boolean, ParameterDirection.Input);
                //DbParameter dbparam4 = DAC.Parameter("@ISACTIVE", ISACTIVE, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@paraandor", andor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3,dbparam4};
                DataTable dt = DAC.Select("LINKS_GET", dbparamcall);
                return dt;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }

    }
}
